package com.movisol.messenger.views.controls;


import java.text.SimpleDateFormat;
import java.util.Date;

import android.content.Context;
import android.view.LayoutInflater;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.movisol.messenger.R;

public class Bubble extends LinearLayout {
	
	private String text;
	private final TextView username;
	private final TextView date;
	private TextView messageChat;
	private LinearLayout baseLayout;
	private LinearLayout backgLayout;
	private LinearLayout messageLayout;
	private final Globito globo;


	public Bubble(Context context, String text, int maxWidth, boolean right, String username, Date date, int color) {
		super(context);
		this.text = text;
		
		String infService = Context.LAYOUT_INFLATER_SERVICE;
		LayoutInflater li = (LayoutInflater)context.getSystemService(infService);
		
		if(right)
			li.inflate(R.layout.bubble_right, this, true);
		else
			li.inflate(R.layout.bubble_left, this, true);
		
		messageChat = (TextView) findViewById(R.id.messageChat);
		baseLayout = (LinearLayout) findViewById(R.id.baseLayout);
		backgLayout = (LinearLayout) findViewById(R.id.backgLayout);
		messageLayout = (LinearLayout) findViewById(R.id.messageLayout);
		this.username = (TextView) findViewById(R.id.tvUserNameChat);
		this.date = (TextView) findViewById(R.id.tvDateChat);
		
		this.username.setText(username);
		SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
		this.date.setText(sdf.format(date));


		messageChat.setText(text);
		messageChat.setMaxWidth(maxWidth);
		messageLayout.measure(0, 0);
		
		this.globo = new Globito(messageLayout.getMeasuredWidth(), messageLayout.getMeasuredHeight(), right, color,
				context.getResources().getDisplayMetrics().density);
		
		backgLayout.setBackgroundDrawable(this.globo);
		
		
	}


	public String getText() {
		return text;
	}


	public void setText(String text) {
		this.text = text;
	}


	public TextView getMessageChat() {
		return messageChat;
	}


	public void setMessageChat(TextView messageChat) {
		this.messageChat = messageChat;
	}


	public LinearLayout getBaseLayout() {
		return baseLayout;
	}


	public void setBaseLayout(LinearLayout baseLayout) {
		this.baseLayout = baseLayout;
	}


	public LinearLayout getBackgLayout() {
		return backgLayout;
	}


	public void setBackgLayout(LinearLayout backgLayout) {
		this.backgLayout = backgLayout;
	}


	public LinearLayout getPaddingTextLayout() {
		return messageLayout;
	}


	public void setPaddingTextLayout(LinearLayout paddingTextLayout) {
		this.messageLayout = paddingTextLayout;
	}
	
	

}
